<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<button>点击</button>
	</body>
	<script>
		var that;
		class Star {
			constructor(arg) {
				//constructor中的this指向的是实例对象
				that = this;
				console.log(this)
				this.arg = arg;
			    this.btn = document.querySelector("button");
				this.btn.onclick = this.sing;
			}
			sing() {
				//this指向调用者，所以在该情况下this.arg是undefined,因为该this指向的是
				//btn，btn没有arg
				console.log(that.arg);
			}
		}
		var a = new Star("123");
	</script>
</html>
